#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read() {
    int f=0,t=0;
    char c=getchar();
    while(!isdigit(c)) t|=(c=='-'),c=getchar();
    while(isdigit(c)) f=(f<<3)+(f<<1)+c-48,c=getchar();
    return t?-f:f;
}
void write(int x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar('0'+x%10);
}
signed main(){
	freopen("sub.in","r",stdin);
	freopen("sub.out","w",stdout);
	int t=read();
	while(t--){
		int x=read(),y=read();
		if((x>=0&&y>=0)||(x<=0&&y<=0)){write(0),cout<<'\n';}
		else{
			write(min(abs(x+y),min(abs(x),abs(y)))),cout<<'\n';
		}
	}
	return 0;
}
